{-
 - phc -- the open source PHP compiler
 - See doc/license/README.license for licensing information
 -
 - Definition of the structure for the Macro-Inline Code Generator.
 -
 -}

{-
	Configuration
-}

output_dir "src/generated";
prefix "MICG";
external class "Object";
external class "IR::Node";
external class "String";
use list "List";
use string "String";
use namespace "MICG";

{-
   Top-level structure	
-}

-- Hack so that Node_factory can create a Macro_list.
All ::= Macro* ; 

Macro ::= Signature Rule* Body ;

-- Signature
Signature ::= MACRO_NAME Formal_parameter* ;
Formal_parameter ::= TYPE_NAME PARAM_NAME ;

-- Rules

Rule ::= Equals | Lookup ;

Lookup ::= PARAM_NAME ATTR_NAME ;

Equals ::= left:Expr right:Expr ;
Expr ::= Param | STRING | Lookup | Macro_call | Callback ;

-- This allows the user to add attributes that arent already set.
Param ::= PARAM_NAME ATTR_NAME* ;

-- Body
Body ::= Body_part* ;
Body_part ::= C_CODE | Interpolation | Macro_call | Callback ;

Interpolation ::= Lookup | PARAM_NAME ;
Macro_call ::= MACRO_NAME Expr*;
Callback ::= MACRO_NAME Expr*;

-- For XML debugging, have a list of identifiers
Identifier ::= MACRO_NAME | TYPE_NAME | PARAM_NAME | ATTR_NAME | STRING | C_CODE ;



{-
 - Extra attributes and methods (mixin code)
 -}

#include <iostream>
#include <sstream>
#include <iomanip>
#include "boost/lexical_cast.hpp"
#include "lib/error.h"
#include "lib/Object.h"
#include "lib/List.h"
#include "lib/String.h"
#include "lib/Boolean.h"
#include "lib/Integer.h"
#include "process_ir/IR.h"

class Node : IR::Node
{
};

class Identifier
{
public:
	virtual String* get_value_as_string() = 0;
};

class Param
{
public:
	Param (PARAM_NAME* param_name)
	{
		this->param_name = param_name;
		this->attr_names = new ATTR_NAME_list;
	}
};
